/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.nuage.tiow.ui;

import com.vaadin.ui.Button;
import com.vaadin.ui.Panel;
import java.util.List;
import org.nuage.tiow.bo.CampaignCreator;
import org.nuage.tiow.debug.StaticPlayerFactory;
import org.nuage.tiow.vo.campaign.Campaign;
import org.nuage.tiow.vo.campaign.SystemState;
import org.nuage.tiow.vo.system.SolarSystem;
import org.nuage.tiow.vo.user.Player;

/**
 *
 * @author quentina
 */
public class CampaignPanel extends Panel {

    public CampaignPanel() {
        Button generate = new Button("Generate mock system", this, "generateMockCampaign");
        addComponent(generate);
    }

    public void generateMockCampaign() {
        StaticPlayerFactory factory = new StaticPlayerFactory();
        List<Player> players = factory.getPlayers();

        CampaignCreator creator = new CampaignCreator();
        Campaign campaign = creator.createCampaign("Mock Campaign", "Mock system", players);
        updateCampaign(campaign);
    }

    private void updateCampaign(Campaign campaign) {
        removeAllComponents();

        setCaption(campaign.getName());

        addComponent(new PlayersPanel(campaign.getPlayers()));

        SolarSystem solarSystem = campaign.getSystem();
        addComponent(new SolarSystemPanel(solarSystem));

        SystemState initialState = campaign.getInitialState();
        addComponent(new SolarSystemStatePanel(solarSystem, initialState));
    }
}
